;-----------------------------------------------------------------;
;  Copyright (C) 2011, Ryabov Alex. All rights reserved.          ;
;  Distributed under terms of the GNU General Public License.     ;
;  See file COPYING for details.                                  ;
;-----------------------------------------------------------------;
;  Omaha32                                                        ;
;  /sys32/syscalls.inc                                            ;
;-----------------------------------------------------------------;


count_params equ (sys_table_end - sys_table_size) / 4

int40:
  push edi ecx edx
  cli
  push ds
  push os_data
  pop  ds

  mov  edi,esp
  cmp  eax,count_params
  jae  .end

  mov  ecx,dword [sys_table_size+eax*4]
  mov  edx,ecx
  dec  edx
  shl  edx,2
  add  ebx,edx
 @@:
   push dword [ebx]
   sub	ebx,4
  loop @b

  call dword [sys_table+eax*4]
  mov  esp,edi

 .end:
  pop  ds
  pop  ecx edx edi
  iretd

sys_table:
  dd LoadLibrary     ; 0
  dd GetProcAddress  ; 1
  dd CreateProcess   ; 2
  dd TerminateProcess ; 3
  dd ExitProcess     ; 4

sys_table_size:
  dd 1	     ; 0
  dd 2	     ; 1
  dd 1	     ; 2
  dd 1	     ; 3
  dd 1	     ; 4

sys_table_end: